* Oversight or Representation? Public Opinion and Impeachment Resolutions in Argentina and Brazil
* Mariana Llanos, GIGA
* Anibal Perez-Linan, University of Notre Dame
* Replication file, March 10, 2020


use "1_QuarterlyResolutions.dta", clear

* Descriptives in text
by cowcode: sum legislators

*** Figures 1 and 2 ***

global a1 = tq(1989q2) 
global a2 = tq(1999q3)
global a3 = tq(2001q4)
global a4 = tq(2003q2)
global a5 = tq(2007q4)
global a6 = tq(2015q3)
global a7 = tq(2017q3)

tsline legislators private if ccode == "ARG", tlabel(, format(%tq)) lp(solid shortdash) title("Argentina, 1983-2017") xtitle("") ytitle("") ///
 tline(1999q4 2007q4 2015q4, lp(dot)) tline(1989q3 2001q4 2003q2, lp(longdash)) legend(region(lcolor(none))) ///
 text(12 $a1 "Alfonsin", place(w)) text(15 $a2 "Menem", place(w)) text(7 $a3 "de la Rua", place(w)) /// 
 text(19 $a4  "Duhalde", place(w))  text(5 $a5 "Kirchner", place(w)) text(10 $a6 "Fernandez", place(w)) text(6 $a7 "Macri", place(w))
 graph save "G\Argentina.gph", replace
 
tsline approval if ccode == "ARG", tlabel(, format(%tq)) title("Argentina, 1983-2017") xtitle("") ytitle("")  ///
 tline(1999q4 2007q4 2015q4, lp(dot)) tline(1989q3 2001q4 2003q2, lp(longdash)) legend(region(lcolor(none))) ///
 text(30 $a1 "Alfonsin", place(w)) text(50 $a2 "Menem", place(w)) text(80 $a3 "de la Rua", place(w)) /// 
 text(5 $a4  "Duhalde", place(w))  text(45 $a5 "Kirchner", place(w)) text(37 $a6 "Fernandez", place(w)) text(70 $a7 "Macri", place(w))
 graph save "G\Argentina2.gph", replace
 
global p7 = tq(1992q2)
global p8 = tq(1994q4)
global p9 = tq(2002q2)
global p10 = tq(2010q2)
global p11 = tq(2015q4)
global p12 = tq(2018q1) 
 
tsline legislators private if ccode == "BRA", tlabel(, format(%tq)) lp(solid shortdash) title("Brazil, 1990-2017") xtitle("") ytitle("") ///
 tline(1995q1 2003q1 2011q1, lp(dot)) tline(1992q4 2016q3, lp(dash)) legend(region(lcolor(none))) ///
 text(10 $p7 "Collor", place(w)) text(25 $p8 "Franco", place(w)) text(15 $p9 "Cardoso", place(w)) text(10 $p10 "Lula", place(w)) ///
 text(23 $p11 "Rousseff", place(w)) text(19 $p12 "Temer", place(w))
 graph save "G\Brazil.gph", replace
 
tsline approval if ccode == "BRA", tlabel(, format(%tq)) title("Brazil, 1990-2017") xtitle("") ytitle("")  ///
 tline(1995q1 2003q1 2011q1, lp(dot)) tline(1992q4 2016q3, lp(dash)) legend(region(lcolor(none))) ///
 text(12 $p7 "Collor", place(w)) text(45 $p8 "Franco", place(w)) text(50 $p9 "Cardoso", place(w)) text(47 $p10 "Lula", place(w)) ///
 text(6 $p11 "Rousseff", place(w)) text(19 $p12 "Temer", place(w))
 graph save "G\Brazil2.gph", replace

* Figure 1
graph combine "G\Argentina.gph" "G\Brazil.gph", ycommon xcommon rows(2) xsize(7) ysize(6)
 graph save Figure1.gph, replace
* Figure 2
graph combine "G\Argentina2.gph" "G\Brazil2.gph", ycommon xcommon rows(2) xsize(7) ysize(5.5)
 graph save Figure2.gph, replace

 
*** Analysis *** 
 
** Tables 1 and 2: SEM - Quarterly

gsem ///
     (approval_1    -> approval, family(gaussian) link(identity))    ///
	 (legislators_1 -> approval, family(gaussian) link(identity))    ///
	 (approval_1    -> legislators, family(gaussian) link(identity)) ///
	 (legislators_1 -> legislators, family(gaussian) link(identity)) /// 
	 if ccode=="ARG", ginvariant(none) cov( e.legislators*e.approval) nocapslatent	 
estimate store q1	 

gsem ///
     (approval_1    -> approval, family(gaussian) link(identity))    ///
	 (legislators_1 -> approval, family(gaussian) link(identity))    ///
	 (approval_1    -> legislators, family(gaussian) link(identity)) ///
	 (legislators_1 -> legislators, family(gaussian) link(identity)) /// 
	 if ccode=="BRA", ginvariant(none) cov( e.legislators*e.approval) nocapslatent	 
estimate store q2	

gsem ///
     (approval_1    -> approval, family(gaussian) link(identity))    ///
	 (legislators_1 -> approval, family(gaussian) link(identity))    ///
	 (private_1     -> approval, family(gaussian) link(identity))    ///
	 (qgrowth_1     -> approval, family(gaussian) link(identity))    ///
	 (inflation_1   -> approval, family(gaussian) link(identity))    ///
	 (antigov_1     -> approval, family(gaussian) link(identity))    ///
 	 (g_h           -> approval, family(gaussian) link(identity))    ///
	 (q1 qL         -> approval, family(gaussian) link(identity))    ///
	 (approval_1    -> legislators, family(gaussian) link(identity)) ///
	 (legislators_1 -> legislators, family(gaussian) link(identity)) /// 
 	 (private_1     -> legislators, family(gaussian) link(identity)) ///
	 (qgrowth_1     -> legislators, family(gaussian) link(identity)) ///
	 (inflation_1   -> legislators, family(gaussian) link(identity)) ///
	 (antigov_1     -> legislators, family(gaussian) link(identity)) ///
 	 (g_h           -> legislators, family(gaussian) link(identity)) ///
	 (q1 qL         -> legislators, family(gaussian) link(identity)) ///
	 if ccode=="ARG", ginvariant(none) cov( e.legislators*e.approval) nocapslatent
estimate store q3

gsem ///
     (approval_1    -> approval, family(gaussian) link(identity))    ///
	 (legislators_1 -> approval, family(gaussian) link(identity))    ///
	 (private_1     -> approval, family(gaussian) link(identity))    ///
	 (qgrowth_1     -> approval, family(gaussian) link(identity))    ///
	 (inflation_1   -> approval, family(gaussian) link(identity))    ///
	 (antigov_1     -> approval, family(gaussian) link(identity))    ///
 	 (g_h           -> approval, family(gaussian) link(identity))    ///
	 (q1 qL         -> approval, family(gaussian) link(identity))    ///
	 (approval_1    -> legislators, family(gaussian) link(identity)) ///
	 (legislators_1 -> legislators, family(gaussian) link(identity)) /// 
 	 (private_1     -> legislators, family(gaussian) link(identity)) ///
	 (qgrowth_1     -> legislators, family(gaussian) link(identity)) ///
	 (inflation_1   -> legislators, family(gaussian) link(identity)) ///
	 (antigov_1     -> legislators, family(gaussian) link(identity)) ///
 	 (g_h           -> legislators, family(gaussian) link(identity)) ///
	 (q1 qL         -> legislators, family(gaussian) link(identity)) ///
	 if ccode=="BRA", ginvariant(none) cov( e.legislators*e.approval) nocapslatent	
estimate store q4

*Tables 1 and 2
  esttab  q1 q2 q3 q4 /// 
      using "Table_1.rtf", cell(b(star fmt (%9.3f)) se(par)) ///
	  starlevels(* 0.05) replace nobase noomit label  ///
	  title("Tables 1-2. Models with Endogenous Outcomes (Quarterly)") ///
	  mtitles("ARG" "BRA" "ARG" "BRA") ///
	  varlabels(_cons Constant)
	  
* Comparison Menem v Cardoso

list president if president == 1403 & president[_n-1] != 1403
 sum legislators if president == 1403
list president if president == 1602 & president[_n-1] != 1602
 sum legislators if president == 1602
	  
	  
** Table 3: SEM - Monthly 

use "1_MonthlyResolutions.dta", clear

gsem ///
     (approval_1    -> approval, family(gaussian) link(identity))    ///
	 (legislators_1 -> approval, family(gaussian) link(identity))    ///
	 (private_1     -> approval, family(gaussian) link(identity))    ///
	 (qgrowth_1     -> approval, family(gaussian) link(identity))    ///
	 (inflation_1   -> approval, family(gaussian) link(identity))    ///
	 (antigov_1     -> approval, family(gaussian) link(identity))    ///
 	 (g_h           -> approval, family(gaussian) link(identity))    ///	 
	 (q1 qL         -> approval, family(gaussian) link(identity))    ///
	 (approval_1    -> legislators, family(gaussian) link(identity)) ///
	 (legislators_1 -> legislators, family(gaussian) link(identity)) /// 
 	 (private_1     -> legislators, family(gaussian) link(identity)) ///
	 (qgrowth_1     -> legislators, family(gaussian) link(identity)) ///
	 (inflation_1   -> legislators, family(gaussian) link(identity)) ///
	 (antigov_1     -> legislators, family(gaussian) link(identity)) ///
 	 (g_h           -> legislators, family(gaussian) link(identity)) ///
	 (q1 qL         -> legislators, family(gaussian) link(identity)) ///
	 if ccode=="ARG", ginvariant(none) cov( e.legislators*e.approval) nocapslatent
estimate store m3

gsem ///
     (approval_1    -> approval, family(gaussian) link(identity))    ///
	 (legislators_1 -> approval, family(gaussian) link(identity))    ///
	 (private_1     -> approval, family(gaussian) link(identity))    ///
	 (qgrowth_1     -> approval, family(gaussian) link(identity))    ///
	 (inflation_1   -> approval, family(gaussian) link(identity))    ///
	 (antigov_1     -> approval, family(gaussian) link(identity))    ///
 	 (g_h           -> approval, family(gaussian) link(identity))    ///
	 (q1 qL         -> approval, family(gaussian) link(identity))    ///
	 (approval_1    -> legislators, family(gaussian) link(identity)) ///
	 (legislators_1 -> legislators, family(gaussian) link(identity)) /// 
 	 (private_1     -> legislators, family(gaussian) link(identity)) ///
	 (qgrowth_1     -> legislators, family(gaussian) link(identity)) ///
	 (inflation_1   -> legislators, family(gaussian) link(identity)) ///
	 (antigov_1     -> legislators, family(gaussian) link(identity)) ///
 	 (g_h           -> legislators, family(gaussian) link(identity)) ///
	 (q1 qL         -> legislators, family(gaussian) link(identity)) ///
	 if ccode=="BRA", ginvariant(none) cov( e.legislators*e.approval) nocapslatent	
estimate store m4

*Table 3
  esttab  m3 m4 /// 
      using "Table_3.rtf", cell(b(star fmt (%9.3f)) se(par))  ///
	  starlevels(* 0.05) replace nobase noomit label  ///
	  title("Table 3. Simulataneous Equations (Monthly)")  ///
	  mtitles("ARG" "BRA" "ARG" "BRA") ///
	  varlabels(_cons Constant)
	  
	 
** Table 4 Count Models
	 
use "1_QuarterlyResolutions.dta", clear
sum legislators 

xtgee legislators approval_1 legislators_1 private_1 qgrowth_1 inflation_1 antigov_1 g_h q1 qL if ccode == "ARG", f(p) corr(ar1) 
  est store q41  
   estat wcorr, c
  margins, at(approval_1=(10(10)70))
   marginsplot, recast(line) recastci(rarea) title("Argentina (Model 4.1)") ytitle("Predicted number of resolutions") 
   graph save 41.gph, replace
xtgee legislators approval_1 legislators_1 private_1 qgrowth_1 inflation_1 antigov_1 g_h q1 qL if ccode == "BRA", f(p) corr(ar1) 
  est store q42  
   estat wcorr, c
  margins, at(approval_1=(10(10)70))
   marginsplot, recast(line) recastci(rarea) title("Brazil (Model 4.2)") ytitle("Predicted number of resolutions") 
   graph save 42.gph, replace

nbreg legislators approval_1 legislators_1 private_1 qgrowth_1 inflation_1 antigov_1 g_h q1 qL if ccode == "ARG" // Set alpha
xtgee legislators approval_1 legislators_1 private_1 qgrowth_1 inflation_1 antigov_1 g_h q1 qL if ccode == "ARG", f(nb .6991067) corr(ar1) 
  est store q43 
    estat wcorr, c

nbreg legislators approval_1 legislators_1 private_1 qgrowth_1 inflation_1 antigov_1 g_h q1 qL if ccode == "BRA" // Set alpha
xtgee legislators approval_1 legislators_1 private_1 qgrowth_1 inflation_1 antigov_1 g_h q1 qL if ccode == "BRA", f(nb  1.482706) corr(ar1) 
  est store q44  
     estat wcorr, c
  
*Table 4
  esttab  q41 q42 q43 q44 /// 
      using "Table_4.rtf", cell(b(star fmt (%9.3f)) se(par)) ///
	  starlevels(* 0.05) replace nobase noomit label  ///
	  title("Table 4. Autoregressive Count Models of Impeachment Resolutions (Quarterly)") ///
	  mtitles("ARG" "BRA" "ARG" "BRA") ///
	  varlabels(_cons Constant)
  
  
 ** Figure 4 - Predicted Values
 
 graph combine 41.gph 42.gph, ycommon xcommon rows(1) xsize(7) ysize(6)
 graph save Figure4.gph, replace
	 
